#include "molvolumecontrol.h"
#include "molecularvolume.h"

using namespace PBVP;

MolVolumeControl::MolVolumeControl(MolVolumePlugin *pVolPlugin, QWidget *parent)
	: QDialog(parent)
{
	ui.setupUi(this);
	m_pVolPlugin = pVolPlugin;
}

MolVolumeControl::~MolVolumeControl()
{

}

void MolVolumeControl::init(BlurMap *pBlur)
{
	unsigned int dim[3];
	double minExt[3], maxExt[3];

	pBlur->getDimension(dim);
	pBlur->getMinMaxExt(minExt, maxExt);
	ui.xDimBox->setValue(dim[0]);
	ui.yDimBox->setValue(dim[1]);
	ui.zDimBox->setValue(dim[2]);
	ui.minXExt->setText(QString().setNum(minExt[0]));
	ui.minYExt->setText(QString().setNum(minExt[1]));
	ui.minZExt->setText(QString().setNum(minExt[2]));
	ui.maxXExt->setText(QString().setNum(maxExt[0]));
	ui.maxYExt->setText(QString().setNum(maxExt[1]));
	ui.maxZExt->setText(QString().setNum(maxExt[2]));
	ui.blobbyEdit->setText(QString().setNum(pBlur->blobby()));
}

void MolVolumeControl::updateBlurMap(BlurMap *pBlur)
{
	unsigned int dim[3];

	dim[0] = ui.xDimBox->value();
	dim[1] = ui.yDimBox->value();
	dim[2] = ui.zDimBox->value();
	pBlur->setDimension(dim);

	double minExt[3], maxExt[3];
	minExt[0] = ui.minXExt->text().toDouble();
	minExt[1] = ui.minYExt->text().toDouble();
	minExt[2] = ui.minZExt->text().toDouble();
	maxExt[0] = ui.maxXExt->text().toDouble();
	maxExt[1] = ui.maxYExt->text().toDouble();
	maxExt[2] = ui.maxZExt->text().toDouble();
	pBlur->setMinMaxExt(minExt, maxExt);

	double blobby;
	blobby = ui.blobbyEdit->text().toDouble();
	pBlur->setBlobby(blobby);
}